package com.ttbj.move_rule.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.alipay.api.internal.util.StringUtils;
import com.ttbj.exception.WebException;
import com.ttbj.move_rule.dao.BillSecondMapper;
import com.ttbj.move_rule.po.BillSecond;
import com.ttbj.move_rule.service.MoveBillStrategy;
import com.ttbj.rule.dao.CarTypeRuleMapper;
import com.ttbj.rule.po.CarTypeRule;
import com.ttbj.util.Assert;
import com.ttbj.util.ResultUtil;
import com.ttbj.util.ViewModelUtil;

import lombok.extern.log4j.Log4j;

/**
 * 按次计费  
 * @author Medivh
 */
@Component
public class TimeMoveBillStrategy implements MoveBillStrategy {
	private static Logger logger = LoggerFactory.getLogger(TimeMoveBillStrategy.class);
	@Autowired
	private CarTypeRuleMapper carTypeRuleMapper = null;

	@Override
	public Float strategyInterface(Integer billType, String senderLat, String senderLng, String reciverLat, String reciverLng, Integer floorNum, Integer pieceNum, Integer baleNum, String truckType, Integer serciveLevel, Integer orderDriverRequire) throws Exception {
		Assert.assertNumeric(truckType,421);
		CarTypeRule rule = carTypeRuleMapper.selectByCarType(truckType);
		Assert.assertNonNullField(rule, 241, "typePrice");
		Float typePrice = rule.getTypePrice();
		logger.info("车辆类型费用:{typePrice}元");
		if(typePrice.equals(0f)){
			ResultUtil.throwExcepion(ResultUtil.createFail("messages", 242));
		}
		return typePrice * orderDriverRequire;
	}
	
	 
	
}
